package com.jservice.api.service.smk;

import com.jfinal.plugin.activerecord.Db;
import com.jservice.api.dto.Request;
import com.jservice.api.dto.Response;
import com.jservice.api.dto.ResponseHeader;
import com.jservice.api.service.BaseService;
import com.jservice.api.service.IService;
import com.jservice.api.smkAppUser.AppUserKit;
import com.jservice.model.SmkAppUser;
import com.jservice.model.SmkSms;
import org.springframework.stereotype.Service;

/**
 * Smk0017 - 查询未读消息数量
 *
 * @Author cwledit
 * @DATE 2017/6/16.
 */
@Service("smk0017")
public class Smk0017 extends BaseService implements IService{

    @Override
    public Response excute(Request request, Response response, ResponseHeader header, String method) throws Exception {
        SmkAppUser smkAppUser = AppUserKit.getCurrent(request);
        if (smkAppUser == null){
            return renderSUC(0,response,header);
        }
        String account = smkAppUser.getIdCard();
        String sql = " select count(*) from "+ SmkSms.TABLE_NAME +" where account = ? and status = 0";
        long count = Db.queryLong(sql,account);
        return renderSUC(count,response,header);

    }
}
